package parser.lr;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

class Production {
    String father;
    String[] sons;

    public Production(String father, String[] sons) {
        this.father = father;
        this.sons = sons;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Production production = (Production) o;
        return father.equals(production.father) && sons.equals(production.sons);
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 31 * hash + Objects.hashCode(this.father);
        hash = 31 * hash + Arrays.deepHashCode(this.sons);
        return hash;
    }

    @Override
    public String toString() {
        String tempSons = "";
        for (int i = 0; i < sons.length; ++i) {
            tempSons = tempSons + sons[i] + " ";
        }
        return father + " --> " + tempSons;
    }
}